package org.chinarjy.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class  ResultApi<T> implements Serializable {
    private boolean success;
    private T data;
    private String errCode;
    private String errMsg;

    public static <T> ResultApi<T> success(){
        return new ResultApi<T>(true,null,"","");
    }

    public static <T> ResultApi<T> success(T data){
        return new ResultApi<T>(true,data,"","");
    }

    public static <T> ResultApi<T> error(String errCode,String errMsg){
        return new ResultApi<T>(false,null,errCode,errMsg);
    }
}
